home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Graphics / Utility / ARTAbrot 1.1 / Menu_ARTAbrot.c < prev    next >
Text File  |  1993-11-22  |  6KB  |  181 lines

  1. /*  Menu_ARTAbrot                                 Handle a selection of the menu bar */
  2.  
  3. /* File name:  Menu_ARTAbrot.c   
  4.  Function:  This module calls the appropiate menu list 
  5.       handler routine. 
  6. History: 8/18/93 Original by George Warner
  7.    */
  8.  
  9.  
  10. #include "ComUtil_ARTAbrot.h"    /* Common */
  11.  
  12. #include "AB_Alert.h"    /* Alert */
  13. #include "About_ARTAbrot.h"    /* Modeless Dialog */
  14. #include "Enter_Coordinates.h"    /* Modeless Dialog */
  15. #include "ARTAbrot.h"    /* Window */
  16. #include "BrotCode.h"
  17. #include "Menu_ARTAbrot.h"    /* This file */
  18.  
  19.  
  20. #pragma segment Menus
  21.  
  22. extern int processing_brot;
  23.  
  24. /* Routine: Init_My_Menus */
  25. /* Purpose: Load in the menu lists and initialize the menubar */
  26.  
  27. void Init_My_Menus()
  28. {
  29.  
  30. ClearMenuBar();                                    /* Clear any old menu bars */
  31. /* This menu is the APPLE menu, used for About and desk accessories */
  32. Menu_Apple = GetMenu(Res_Menu_Apple);                /* Get the menu from the resource file */
  33. InsertMenu(Menu_Apple,0);                            /* Insert this menu into the menu bar */
  34.  
  35. AddResMenu(Menu_Apple,'DRVR');                        /* Add in DAs */
  36.  
  37. /* This menu is  File */
  38. Menu_File = GetMenu(Res_Menu_File);                /* Get the menu from the resource file */
  39. InsertMenu(Menu_File,0);                            /* Insert this menu into the menu bar */
  40.  
  41. /* This menu is  Commands */
  42. Menu_Commands = GetMenu(Res_Menu_Commands);        /* Get the menu from the resource file */
  43. InsertMenu(Menu_Commands,0);                        /* Insert this menu into the menu bar */
  44.  
  45.  
  46. DrawMenuBar();                                        /* Draw the menu bar */
  47. }
  48.  
  49. /* ======================================================= */
  50. void DoMenuApple(short theItem);                    /* Handle this menu list */
  51. void DoMenuFile(short theItem);                    /* Handle this menu list */
  52. void DoMenuCommands(short theItem);                /* Handle this menu list */
  53. /* ======================================================= */
  54.  
  55. /* Routine: Pre_Do_MenuListApple */
  56. /* Purpose: Handle all menu items in this list */
  57.  
  58. void DoMenuApple(short theItem)
  59. {
  60. Boolean    SkipProcessing;                            /* TRUE says skip processing */
  61. short    DNA;                                        /* For opening DAs */
  62. Str255    DAName;                                    /* For getting DA name */
  63. GrafPtr    SavePort;                                /* Save current port when opening DAs */
  64.  
  65. SkipProcessing = false;                            /* Set to not skip the processing of this menu item */
  66.  
  67. if (SkipProcessing == false)                        /* See if process the menu list */
  68.     {
  69.  
  70.     switch (theItem)                                /* Handle all commands in this menu list */
  71.         {
  72.         case MItem_About:
  73.             Add_UserEvent(UserEvent_Open_Window,Res_MD_About_ARTAbrot,0,0,NIL);/* Open a modeless dialog */
  74.             break;
  75.         default:                                /* allow other buttons, trap for debug */
  76.             GetPort(&SavePort);                    /* Save the current port */
  77.             GetItem(Menu_Apple, theItem, DAName);    /* Get the name of the DA selected */
  78.             DNA = OpenDeskAcc(DAName);                /* Open the DA selected */
  79.             SetPort(SavePort);                        /* Restore to the saved port */
  80.             break;                            /* end of otherwise */
  81.         }                                        /* end of switch */
  82.  
  83.     }                                            /* End of IF */
  84.  
  85. }
  86.  
  87. /* ======================================================= */
  88.  
  89. /* Routine: Pre_Do_MenuListFile */
  90. /* Purpose: Handle all menu items in this list */
  91.  
  92. void DoMenuFile(short theItem)
  93. {
  94. Boolean    SkipProcessing;                            /* TRUE says skip processing */
  95.  
  96. SkipProcessing = false;                            /* Set to not skip the processing of this menu item */
  97.  
  98. if (SkipProcessing == false)                        /* See if process the menu list */
  99.     {
  100.  
  101.     switch (theItem)                                /* Handle all commands in this menu list */
  102.         {
  103.         case MItem_Quit2:
  104.             if (processing_brot)
  105.                 finish_brot();
  106.             doneFlag = true;
  107.             break;
  108.         default:                                /* allow other buttons, trap for debug */
  109.             break;                            /* end of otherwise */
  110.         }                                        /* end of switch */
  111.  
  112.     }                                            /* End of IF */
  113.  
  114. }
  115.  
  116. /* ======================================================= */
  117.  
  118. /* Routine: Pre_Do_MenuListCommands */
  119. /* Purpose: Handle all menu items in this list */
  120.  
  121. void DoMenuCommands(short theItem)
  122. {
  123. Boolean    SkipProcessing;                            /* TRUE says skip processing */
  124. Boolean    BoolHolder;                                /* For SystemEdit result */
  125.  
  126. SkipProcessing = false;                            /* Set to not skip the processing of this menu item */
  127.  
  128. if (SkipProcessing == false)                        /* See if process the menu list */
  129.     {
  130.  
  131.     BoolHolder = SystemEdit(theItem - 1);            /* Let the DA do the edit to itself */
  132.  
  133.     if  (BoolHolder == false)                        /* If not a DA then we get it */
  134.         {
  135.  
  136.         switch (theItem)                            /* Handle all commands in this menu list */
  137.             {
  138.             case MItem_Enter_Coordinat:
  139.                 Add_UserEvent(UserEvent_Open_Window,Res_MD_Enter_Coordinat,0,0,NIL);/* Open a modeless dialog */
  140.                 break;
  141.             case MItem_Display:
  142.                 Add_UserEvent(UserEvent_Open_Window,Res_W_ARTAbrot,0,0,NIL);/* Open a Window */
  143.                 break;
  144.             default:                            /* allow other buttons, trap for debug */
  145.                 break;                        /* end of otherwise */
  146.             }                                    /* end of switch */
  147.         }                                        /* End of IF */
  148.  
  149.     }                                            /* End of IF */
  150.  
  151. }
  152.  
  153. /* ======================================================= */
  154.  
  155. /* Routine: Handle_My_Menu */
  156. /* Purpose: Vector off to the appropiate menu list handler */
  157.  
  158. void Handle_My_Menu(short theMenu,short theItem)
  159. {
  160.  
  161. switch (theMenu)                                    /* Do selected menu list */
  162.     {
  163.     case Res_Menu_Apple:
  164.         DoMenuApple(theItem);                        /* Go handle this menu list */
  165.         break;
  166.     case Res_Menu_File:
  167.         DoMenuFile(theItem);                        /* Go handle this menu list */
  168.         break;
  169.     case Res_Menu_Commands:
  170.         DoMenuCommands(theItem);                    /* Go handle this menu list */
  171.         break;
  172.     default:                                    /* allow other buttons, trap for debug */
  173.         break;                                /* end of otherwise */
  174.     }                                            /* end of switch */
  175.  
  176. HiliteMenu(0);                                        /* Turn menu selection off */
  177. }
  178.  
  179. /* ======================================================= */
  180.  
  181.